import { ref, computed } from 'vue'
import { defineStore } from 'pinia'

export const useCounterStore = defineStore('counter', () => {
  const count = ref(0)
  const aaa = ref(100)
  const doubleCount = computed(() => count.value * 2)
  function increment(val) {
    count.value = count.value + val
  }
  function decrement(val){
    if(count.value - val < 0){
      alert('别贪心了，金库没钱了')
    }
    else{count.value = count.value -val
  }}
  return { count, doubleCount, increment ,aaa , decrement}
})
export default useCounterStore
